/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.VideoEntry;
import vn.com.fis.portal.model.VideoEntryModel;
import vn.com.fis.portal.model.VideoEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VideoEntry service. Represents a row in the &quot;TBL_VIDEO&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.VideoEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VideoEntryImpl}.
 * </p>
 *
 * @author loind
 * @see VideoEntryImpl
 * @see vn.com.fis.portal.model.VideoEntry
 * @see vn.com.fis.portal.model.VideoEntryModel
 * @generated
 */
@JSON(strict = true)
public class VideoEntryModelImpl extends BaseModelImpl<VideoEntry>
	implements VideoEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a video entry model instance should use the {@link vn.com.fis.portal.model.VideoEntry} interface instead.
	 */
	public static final String TABLE_NAME = "TBL_VIDEO";
	public static final Object[][] TABLE_COLUMNS = {
			{ "videoId", Types.BIGINT },
			{ "videoName", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "videoUrl", Types.VARCHAR },
			{ "viewCount", Types.BIGINT },
			{ "date_", Types.TIMESTAMP },
			{ "smallImageUrl", Types.VARCHAR },
			{ "largeImageUrl", Types.VARCHAR },
			{ "accessModifier", Types.INTEGER },
			{ "uploaderId", Types.BIGINT },
			{ "folderId", Types.BIGINT },
			{ "status", Types.INTEGER }
		};
	public static final String TABLE_SQL_CREATE = "create table TBL_VIDEO (videoId LONG not null primary key,videoName VARCHAR(75) null,description VARCHAR(75) null,videoUrl VARCHAR(75) null,viewCount LONG,date_ DATE null,smallImageUrl VARCHAR(75) null,largeImageUrl VARCHAR(75) null,accessModifier INTEGER,uploaderId LONG,folderId LONG,status INTEGER)";
	public static final String TABLE_SQL_DROP = "drop table TBL_VIDEO";
	public static final String ORDER_BY_JPQL = " ORDER BY videoEntry.videoName ASC, videoEntry.date_ ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TBL_VIDEO.videoName ASC, TBL_VIDEO.date_ ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.VideoEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.VideoEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.VideoEntry"),
			true);
	public static long DATE__COLUMN_BITMASK = 1L;
	public static long FOLDERID_COLUMN_BITMASK = 2L;
	public static long UPLOADERID_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VideoEntry toModel(VideoEntrySoap soapModel) {
		VideoEntry model = new VideoEntryImpl();

		model.setVideoId(soapModel.getVideoId());
		model.setVideoName(soapModel.getVideoName());
		model.setDescription(soapModel.getDescription());
		model.setVideoUrl(soapModel.getVideoUrl());
		model.setViewCount(soapModel.getViewCount());
		model.setDate_(soapModel.getDate_());
		model.setSmallImageUrl(soapModel.getSmallImageUrl());
		model.setLargeImageUrl(soapModel.getLargeImageUrl());
		model.setAccessModifier(soapModel.getAccessModifier());
		model.setUploaderId(soapModel.getUploaderId());
		model.setFolderId(soapModel.getFolderId());
		model.setStatus(soapModel.getStatus());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VideoEntry> toModels(VideoEntrySoap[] soapModels) {
		List<VideoEntry> models = new ArrayList<VideoEntry>(soapModels.length);

		for (VideoEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.VideoEntry"));

	public VideoEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _videoId;
	}

	public void setPrimaryKey(long primaryKey) {
		setVideoId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_videoId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return VideoEntry.class;
	}

	public String getModelClassName() {
		return VideoEntry.class.getName();
	}

	@JSON
	public long getVideoId() {
		return _videoId;
	}

	public void setVideoId(long videoId) {
		_videoId = videoId;
	}

	@JSON
	public String getVideoName() {
		if (_videoName == null) {
			return StringPool.BLANK;
		}
		else {
			return _videoName;
		}
	}

	public void setVideoName(String videoName) {
		_columnBitmask = -1L;

		_videoName = videoName;
	}

	@JSON
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	@JSON
	public String getVideoUrl() {
		if (_videoUrl == null) {
			return StringPool.BLANK;
		}
		else {
			return _videoUrl;
		}
	}

	public void setVideoUrl(String videoUrl) {
		_videoUrl = videoUrl;
	}

	@JSON
	public long getViewCount() {
		return _viewCount;
	}

	public void setViewCount(long viewCount) {
		_viewCount = viewCount;
	}

	@JSON
	public Date getDate_() {
		return _date_;
	}

	public void setDate_(Date date_) {
		_columnBitmask = -1L;

		if (_originalDate_ == null) {
			_originalDate_ = _date_;
		}

		_date_ = date_;
	}

	public Date getOriginalDate_() {
		return _originalDate_;
	}

	@JSON
	public String getSmallImageUrl() {
		if (_smallImageUrl == null) {
			return StringPool.BLANK;
		}
		else {
			return _smallImageUrl;
		}
	}

	public void setSmallImageUrl(String smallImageUrl) {
		_smallImageUrl = smallImageUrl;
	}

	@JSON
	public String getLargeImageUrl() {
		if (_largeImageUrl == null) {
			return StringPool.BLANK;
		}
		else {
			return _largeImageUrl;
		}
	}

	public void setLargeImageUrl(String largeImageUrl) {
		_largeImageUrl = largeImageUrl;
	}

	@JSON
	public int getAccessModifier() {
		return _accessModifier;
	}

	public void setAccessModifier(int accessModifier) {
		_accessModifier = accessModifier;
	}

	@JSON
	public long getUploaderId() {
		return _uploaderId;
	}

	public void setUploaderId(long uploaderId) {
		_columnBitmask |= UPLOADERID_COLUMN_BITMASK;

		if (!_setOriginalUploaderId) {
			_setOriginalUploaderId = true;

			_originalUploaderId = _uploaderId;
		}

		_uploaderId = uploaderId;
	}

	public long getOriginalUploaderId() {
		return _originalUploaderId;
	}

	@JSON
	public long getFolderId() {
		return _folderId;
	}

	public void setFolderId(long folderId) {
		_columnBitmask |= FOLDERID_COLUMN_BITMASK;

		if (!_setOriginalFolderId) {
			_setOriginalFolderId = true;

			_originalFolderId = _folderId;
		}

		_folderId = folderId;
	}

	public long getOriginalFolderId() {
		return _originalFolderId;
	}

	@JSON
	public int getStatus() {
		return _status;
	}

	public void setStatus(int status) {
		_status = status;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VideoEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VideoEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					VideoEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		VideoEntryImpl videoEntryImpl = new VideoEntryImpl();

		videoEntryImpl.setVideoId(getVideoId());
		videoEntryImpl.setVideoName(getVideoName());
		videoEntryImpl.setDescription(getDescription());
		videoEntryImpl.setVideoUrl(getVideoUrl());
		videoEntryImpl.setViewCount(getViewCount());
		videoEntryImpl.setDate_(getDate_());
		videoEntryImpl.setSmallImageUrl(getSmallImageUrl());
		videoEntryImpl.setLargeImageUrl(getLargeImageUrl());
		videoEntryImpl.setAccessModifier(getAccessModifier());
		videoEntryImpl.setUploaderId(getUploaderId());
		videoEntryImpl.setFolderId(getFolderId());
		videoEntryImpl.setStatus(getStatus());

		videoEntryImpl.resetOriginalValues();

		return videoEntryImpl;
	}

	public int compareTo(VideoEntry videoEntry) {
		int value = 0;

		value = getVideoName().compareTo(videoEntry.getVideoName());

		if (value != 0) {
			return value;
		}

		value = DateUtil.compareTo(getDate_(), videoEntry.getDate_());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VideoEntry videoEntry = null;

		try {
			videoEntry = (VideoEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = videoEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		VideoEntryModelImpl videoEntryModelImpl = this;

		videoEntryModelImpl._originalDate_ = videoEntryModelImpl._date_;

		videoEntryModelImpl._originalUploaderId = videoEntryModelImpl._uploaderId;

		videoEntryModelImpl._setOriginalUploaderId = false;

		videoEntryModelImpl._originalFolderId = videoEntryModelImpl._folderId;

		videoEntryModelImpl._setOriginalFolderId = false;

		videoEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VideoEntry> toCacheModel() {
		VideoEntryCacheModel videoEntryCacheModel = new VideoEntryCacheModel();

		videoEntryCacheModel.videoId = getVideoId();

		videoEntryCacheModel.videoName = getVideoName();

		String videoName = videoEntryCacheModel.videoName;

		if ((videoName != null) && (videoName.length() == 0)) {
			videoEntryCacheModel.videoName = null;
		}

		videoEntryCacheModel.description = getDescription();

		String description = videoEntryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			videoEntryCacheModel.description = null;
		}

		videoEntryCacheModel.videoUrl = getVideoUrl();

		String videoUrl = videoEntryCacheModel.videoUrl;

		if ((videoUrl != null) && (videoUrl.length() == 0)) {
			videoEntryCacheModel.videoUrl = null;
		}

		videoEntryCacheModel.viewCount = getViewCount();

		Date date_ = getDate_();

		if (date_ != null) {
			videoEntryCacheModel.date_ = date_.getTime();
		}
		else {
			videoEntryCacheModel.date_ = Long.MIN_VALUE;
		}

		videoEntryCacheModel.smallImageUrl = getSmallImageUrl();

		String smallImageUrl = videoEntryCacheModel.smallImageUrl;

		if ((smallImageUrl != null) && (smallImageUrl.length() == 0)) {
			videoEntryCacheModel.smallImageUrl = null;
		}

		videoEntryCacheModel.largeImageUrl = getLargeImageUrl();

		String largeImageUrl = videoEntryCacheModel.largeImageUrl;

		if ((largeImageUrl != null) && (largeImageUrl.length() == 0)) {
			videoEntryCacheModel.largeImageUrl = null;
		}

		videoEntryCacheModel.accessModifier = getAccessModifier();

		videoEntryCacheModel.uploaderId = getUploaderId();

		videoEntryCacheModel.folderId = getFolderId();

		videoEntryCacheModel.status = getStatus();

		return videoEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(25);

		sb.append("{videoId=");
		sb.append(getVideoId());
		sb.append(", videoName=");
		sb.append(getVideoName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", videoUrl=");
		sb.append(getVideoUrl());
		sb.append(", viewCount=");
		sb.append(getViewCount());
		sb.append(", date_=");
		sb.append(getDate_());
		sb.append(", smallImageUrl=");
		sb.append(getSmallImageUrl());
		sb.append(", largeImageUrl=");
		sb.append(getLargeImageUrl());
		sb.append(", accessModifier=");
		sb.append(getAccessModifier());
		sb.append(", uploaderId=");
		sb.append(getUploaderId());
		sb.append(", folderId=");
		sb.append(getFolderId());
		sb.append(", status=");
		sb.append(getStatus());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(40);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.VideoEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>videoId</column-name><column-value><![CDATA[");
		sb.append(getVideoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>videoName</column-name><column-value><![CDATA[");
		sb.append(getVideoName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>videoUrl</column-name><column-value><![CDATA[");
		sb.append(getVideoUrl());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>viewCount</column-name><column-value><![CDATA[");
		sb.append(getViewCount());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>date_</column-name><column-value><![CDATA[");
		sb.append(getDate_());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>smallImageUrl</column-name><column-value><![CDATA[");
		sb.append(getSmallImageUrl());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>largeImageUrl</column-name><column-value><![CDATA[");
		sb.append(getLargeImageUrl());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>accessModifier</column-name><column-value><![CDATA[");
		sb.append(getAccessModifier());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>uploaderId</column-name><column-value><![CDATA[");
		sb.append(getUploaderId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>folderId</column-name><column-value><![CDATA[");
		sb.append(getFolderId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>status</column-name><column-value><![CDATA[");
		sb.append(getStatus());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VideoEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VideoEntry.class
		};
	private long _videoId;
	private String _videoName;
	private String _description;
	private String _videoUrl;
	private long _viewCount;
	private Date _date_;
	private Date _originalDate_;
	private String _smallImageUrl;
	private String _largeImageUrl;
	private int _accessModifier;
	private long _uploaderId;
	private long _originalUploaderId;
	private boolean _setOriginalUploaderId;
	private long _folderId;
	private long _originalFolderId;
	private boolean _setOriginalFolderId;
	private int _status;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private VideoEntry _escapedModelProxy;
}